﻿using System;
using System.Collections.Generic;
using System.Text;

namespace WowGuildSite.Armory
{
    public enum MagicType
    {
        Arcane,
        Fire,
        Frost,
        Holy,
        Nature,
        Shadow,
    }

    public class ArmorySpellStats
    {
        private ArmoryCharacter character;

        public int      BonusHealing
        {
            get
            {
                return character.SheetDocument.GetAttributeInt("/page/characterInfo/characterTab/spell/bonusHealing/@value");
            }
        }

        public int      ArcaneBonusDamage
        {
            get { return GetBonusDamage(MagicType.Arcane); }
        }

        public int      FireBonusDamage
        {
            get { return GetBonusDamage(MagicType.Fire); }
        }

        public int      FrostBonusDamage
        {
            get { return GetBonusDamage(MagicType.Frost); }
        }

        public int      HolyBonusDamage
        {
            get { return GetBonusDamage(MagicType.Holy); }
        }

        public int      NatureBonusDamage
        {
            get { return GetBonusDamage(MagicType.Nature); }
        }

        public int      ShadowBonusDamage
        {
            get { return GetBonusDamage(MagicType.Shadow); }
        }

        public decimal  ArcaneCritChance
        {
            get { return GetCritChance(MagicType.Arcane); }
        }

        public decimal  FireCritChance
        {
            get { return GetCritChance(MagicType.Fire); }
        }

        public decimal  FrostCritChance
        {
            get { return GetCritChance(MagicType.Frost); }
        }

        public decimal  HolyCritChance
        {
            get { return GetCritChance(MagicType.Holy); }
        }

        public decimal  NatureCritChance
        {
            get { return GetCritChance(MagicType.Nature); }
        }

        public decimal  ShadowCritChance
        {
            get { return GetCritChance(MagicType.Shadow); }
        }

        public int      HitRating
        {
            get
            {
                return character.SheetDocument.GetAttributeInt("/page/characterInfo/characterTab/spell/hitRating/@value");
            }
        }

        public int      Penetration
        {
            get
            {
                return character.SheetDocument.GetAttributeInt("/page/characterInfo/characterTab/spell/penetration/@value");
            }
        }

        public decimal  ManaRegenCasting
        {
            get
            {
                return character.SheetDocument.GetAttributeDecimal("/page/characterInfo/characterTab/spell/manaRegen/@casting");
            }
        }

        public decimal  ManaRegen
        {
            get
            {
                return character.SheetDocument.GetAttributeDecimal("/page/characterInfo/characterTab/spell/manaRegen/@notCasting");
            }
        }

        public int      GetBonusDamage(MagicType type)
        {
            return character.SheetDocument.GetAttributeInt(String.Format("/page/characterInfo/characterTab/spell/bonusDamage/{0}/@value", type.ToString().ToLower()));
        }

        public decimal  GetCritChance(MagicType type)
        {
            return character.SheetDocument.GetAttributeDecimal(String.Format("/page/characterInfo/characterTab/spell/critChance/{0}/@percent", type.ToString().ToLower()));
        }

        internal ArmorySpellStats( ArmoryCharacter character )
        {
            if (character == null)
            {
                throw new ArgumentNullException("character");
            }

            this.character = character;
        }
    }
}
